package pl.ydp.ivy.flex.ide.handlers;

import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;

public class RefreshProjectJob extends Job {

	IProject project;
	
	public RefreshProjectJob(String name, IProject project) {
		super(name);
		
		this.project = project;
	}

	@Override
	protected IStatus run(IProgressMonitor monitor) {
		try {
			project.refreshLocal( IResource.DEPTH_INFINITE, monitor );
		} catch (CoreException e) {
			return new Status(Status.ERROR,pl.ydp.ivy.flex.ide.Activator.PLUGIN_ID, e.getMessage(), e );
		}
		
		return Status.OK_STATUS;
	}

}
